package com.android.multiplesmart.utils;

import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.widget.Toast;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class DataUtils {

    public   static void   saveAction(File files, String  data, Context context){
        String state = Environment.getExternalStorageState();
        if (state.equals(Environment.MEDIA_MOUNTED)) {

        try {
            // 打开一个写文件器，构造函数中的第二个参数true表示以追加形式写文件
            FileWriter writer = new FileWriter(files, true);
            writer.write(data+"\r\n");
            writer.flush();
            writer.close();
//            System.out.println(files.getAbsoluteFile());
//            Toast.makeText(context, "已写入", Toast.LENGTH_SHORT).show();
        } catch (IOException e) {
            e.printStackTrace();
         }
        }
    }

    public   static void   saveAction(File files, String  data){
        String state = Environment.getExternalStorageState();
        if (state.equals(Environment.MEDIA_MOUNTED)) {

            try {
                // 打开一个写文件器，构造函数中的第二个参数true表示以追加形式写文件
                FileWriter writer = new FileWriter(files, true);
                writer.write(data+"\r\n");
                writer.flush();
                writer.close();
//            System.out.println(files.getAbsoluteFile());
//            Toast.makeText(context, "已写入", Toast.LENGTH_SHORT).show();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

///storage/emulated/0/Android/data/com.huasi.hshealth.huasi_health/files/text/text.txt

}
